#pragma once
#include "Util.h"
#include "AABB.h"

class CMaterial;

class CHitRecord {
public:
	Point3 m_Point;
	Vec3 m_Normal;
	shared_ptr<CMaterial>m_pMat;
	double m_t;
	double m_u;
	double m_v;
	bool m_FrontFace;

	void setFaceNormal(const CRay& vRay, const Vec3& vOutwardNormal);
};

class CHittable {
public:
	virtual ~CHittable() = default;
	virtual bool hit(const CRay& vR, CInterval vRayT, CHitRecord& vHitRecord)const = 0;
	virtual CAABB boundingBox()const = 0;
};

class CTranslate : public CHittable {
public:
	CTranslate(shared_ptr<CHittable>vObject, const Vec3& vOffset);

	bool hit(const CRay& vR, CInterval vRayT, CHitRecord& vHitRecord)const override;

	CAABB boundingBox()const override { return m_BBox; }
private:
	shared_ptr<CHittable>m_Object;
	Vec3 m_Offset;
	CAABB m_BBox;
};

class CRotateY : public CHittable {
public:
	CRotateY(shared_ptr<CHittable>vObject, double vAngel);

	bool hit(const CRay& vR, CInterval vRayT, CHitRecord& vHitRecord)const override;
	CAABB boundingBox()const override { return m_BBox; }
private:
	shared_ptr<CHittable> m_Object;
	double m_SinTheta;
	double m_CosTheta;
	CAABB m_BBox;
};